package controlLayer;

import java.util.ArrayList;
import java.util.List;

import modelLayer.Room;
import dbLayer.DBRoom;

public class RoomCtrl {
	
	private DBRoom dbRoom = new DBRoom();
	
	public RoomCtrl () {
		
	}
	
	public Room findRoomID (int roomID) {
		
		Room room = null;
		
		room = dbRoom.findRoomID(roomID);
		
		return room;
	}
	
	public Room findRoomName (String roomName) {
		
		Room room = null;
		
		List<Room> resultRoom = new ArrayList<>();
		
		resultRoom = dbRoom.findRoomsName(roomName);
		
		if (resultRoom.size() > 1) {
			System.out.println("More than one room with that name!");
		}
		else if (resultRoom.size() == 1) {
			room = resultRoom.get(0);
		}
		else {
			System.out.println("No room with that name!");
		}
		
		return room;
		
	}
	
	public List<Room> allRooms () {
		
		List<Room> allRooms = new ArrayList<>();
		
		allRooms = dbRoom.allRooms();
		
		return allRooms;
		
	}
	
	public int getHighestID () {
		return dbRoom.highestID();
	}
	
	public void addRoom (Room room) {
		
		dbRoom.addRoom(room);
		
	}
	
	public void updateRoom (Room room) {
		
		dbRoom.updateRoom(room);
		
	}

	public void removeRoom(int roomID) {
		
		dbRoom.removeRoom(roomID);
		
	}

}
